package com.jd.sunny.java.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * @author :Sun Lin
 * @Description: RMI----客户机类的主要功能有两个，一是通过Naming.lookup方法来构造注册服务程序 stub 程序实例
 * 二是调用服务器远程对象上的远程方法。
 * @date :2012-9-24
 * @since:1.0.0
 */
public class SampleRmiClient {

    /**
     * @param args
     * @throws NotBoundException
     * @throws RemoteException
     * @throws MalformedURLException
     */
    public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
        String url = "//localhost:5168/SAMPLE-SERVER";
        SampleRmi sampleRmi = (SampleRmi) Naming.lookup(url);
        int result = sampleRmi.sum(1, 1);
        System.out.println(result);
    }

}
